home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / What's New? / Development Kits / Mac OS / USB DDK 1.4.6f4 / Examples / USBSampleStorageDriver / StorageClassPublicAPI.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-25  |  5.8 KB  |  198 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        StorageClassPublicAPI.h
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Version:    xxx put version here xxx
  7.  
  8.     Copyright:    © 2000 by Apple Computer, Inc., all rights reserved.
  9.  
  10. */
  11.  
  12. /*
  13.     File:        StorageClassPublicAPI.h
  14.  
  15.     Contains:    This contains the API for all Shim and Storage Class Services
  16.  
  17.     Version:    1.3
  18.  
  19.     Copyright:    © 1998-2000 by Apple Computer, Inc., all rights reserved.
  20.  
  21.  
  22. */
  23.  
  24. #ifndef __STORAGECLASSPUBLICAPI__
  25. #define __STORAGECLASSPUBLICAPI__
  26.  
  27. #include <MacTypes.h>
  28. #include <USB.h>
  29.  
  30. // This driver requires USB Manager 1.3 or greater
  31. #define kMinimumUSBMgrVersion    0x01300000
  32.  
  33. // ~~~~~~~~~~~~~~~~~~~~~~~~~~ Storage Class API ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  34. #define kDispatchTableVersion    0x01000000
  35.  
  36. // Return codes from the class driver
  37. enum
  38. {
  39.     kCommandBusyError =  -10000,
  40.     kClassNotConfiguredError,
  41.     kRequestPending = 1
  42. };
  43.  
  44. // USB Mass Storage Services Control Call Selectors
  45. enum
  46. {
  47.     kUSBStorageControlAbortCommand = 0,
  48.     kUSBStorageControlSetParentsRefNumber = 1
  49. };
  50.  
  51. // USB Mass Storage Services Status Call Selectors
  52. enum
  53. {
  54.     kUSBStorageStatusGetServicesStatus = 0,
  55.     kUSBStorageStatusGetDeviceStatus,
  56.     kUSBStorageStatusGetRemovalStatus,
  57.     kUSBStorageStatusGetVendorStringPtr,
  58.     kUSBStorageStatusGetProductStringPtr,
  59.     kUSBStorageStatusGetDeviceReleaseNumber
  60. };
  61.  
  62. // Return results for the kUSBStorageStatusGetServicesStatus
  63. // USB Storage Services Status call
  64. enum
  65. {
  66.     kUSBStorageServicesNotConfigured =            0,
  67.     kUSBStorageServicesConfigureInProgress,
  68.     kUSBStorageServicesConfigureComplete,
  69.     kUSBStorageServicesConfigureFailed,
  70.     kUSBStorageServicesTerminated
  71. };
  72.  
  73. #define kUSBStorageAutoStatusSize    2        // Per the USB CBI Protocol
  74. #define kUSBStorageMaxCDBSize        12        // Per the USB Mass Storage Class spec.
  75.  
  76. typedef CALLBACK_API_C( void , StorageClassCompletionProcPtr )(void* storageClassPBPtr );
  77.  
  78. struct StorageExecuteCommandPB 
  79. {
  80.     UInt8                            cdb[kUSBStorageMaxCDBSize];                // -> CDB to send to device
  81.     UInt32                            flags;                                    // -> Data transfer flags (See below)
  82.     Ptr                                userBuffer;                                // -> Pointer to user buffer
  83.     StorageClassCompletionProcPtr    completionProc;                            // -> Completion routine
  84.     UInt32                            timeout;                                // -> Number of milliseconds until the command timesout
  85.     UInt32                            expectedCount;                            // -> Expected number of bytes to transfer
  86.     UInt32                            actualCount;                            // <- Actual number of bytes transferred
  87.     OSStatus                        status;                                    // <- Result of operation
  88.     UInt8                            autoStatus[kUSBStorageAutoStatusSize];     // <- Device status
  89.     Boolean                            autoStatusIsValid;                        // <- true indicates that the data in autoStatus is valid
  90.     UInt16                            reserved1;                                // Used for padding
  91. };
  92. typedef struct StorageExecuteCommandPB    StorageExecuteCommandPB;
  93. typedef StorageExecuteCommandPB *        StorageExecuteCommandPBPtr;
  94.  
  95. // Data transfer flags for StorageExecuteCommandPB
  96. enum 
  97. {
  98.     kStorageDataIn                    =    0x0001,
  99.     kStorageDataOut                 =    0x0002,
  100.     kStorageNoData                     =    0x0004,
  101.     kStorageSGBuffer                 =    0x0010,
  102.     kStorageUseCommandCompletionInt =    0x0100
  103. };
  104.  
  105. // Structures for Scatter-Gather list suppport
  106. // Read/Write a scatter-gather list entry point
  107. struct USBSGElement {
  108.     Ptr             SGAddr;
  109.     UInt32             SGCount;
  110. };
  111. typedef struct USBSGElement    USBSGElement, *USBSGElementPtr;
  112.  
  113. struct USBSGList
  114. {
  115.     UInt32            sgNumberElements;
  116.     USBSGElementPtr    sgElementList;    
  117. };
  118.  
  119. typedef struct USBSGList USBSGList, *USBSGListPtr;
  120.  
  121. typedef CALLBACK_API_C( OSStatus , StorageInitializeProcPtr )(void);
  122. typedef CALLBACK_API_C( OSStatus , StorageTerminateProcPtr )(void);
  123. typedef CALLBACK_API_C( OSStatus , StorageControlProcPtr )(UInt32 theControlSelector, void *theControlData);
  124. typedef CALLBACK_API_C( OSStatus , StorageStatusProcPtr )(UInt32 theInfoSelector, void *theInfo);
  125. typedef CALLBACK_API_C( OSStatus , StorageExecuteCommandProcPtr )( StorageExecuteCommandPBPtr storageExecuteCommandPBPtr );
  126.  
  127. struct StorageClassDispatchTable 
  128. {
  129.     UInt32                            dispatchTableVersion;
  130.     StorageInitializeProcPtr         pStorageInitialize;
  131.     StorageTerminateProcPtr             pStorageTerminate;
  132.     StorageControlProcPtr             pStorageControl;
  133.     StorageStatusProcPtr             pStorageStatus;
  134.     StorageExecuteCommandProcPtr    pStorageExecuteCmd;
  135. };
  136. typedef struct StorageClassDispatchTable    StorageClassDispatchTable;
  137. typedef StorageClassDispatchTable *            StorageClassDispatchTablePtr;
  138.  
  139. extern StorageClassDispatchTable TheStorageClassDispatchTable;
  140.  
  141. // ~~~~~~~~~~~~~~~~~~~~~~~~~~ Shim API ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  142. // The control calls the Shim makes to the Unit Table driver
  143. // to set the information from the Storage Class
  144. enum
  145. {
  146.     kInitializeDeviceAccess = 500,
  147.     kTerminateDeviceAccess = 501
  148. };
  149.  
  150. enum
  151. {
  152.     kUSBStorageEventRemoveManualEjectMedia = 1,
  153.     kUSBStorageEventManualEjectMediaWasRemoved,
  154.     kUSBStorageEventDeviceWasRemoved,
  155.     kUSBStorageEventUnusableMediaEjected
  156. };
  157.  
  158.  
  159. // Enumerations for Mass Storage Class Subclass types
  160. enum
  161. {
  162.     kUSBStorageRBCSubclass                 = 1,
  163.     kUSBStorageSFF8020iSubclass         = 2,
  164.     kUSBStorageQIC157Subclass            = 3,
  165.     kUSBStorageUFISubclass                = 4,
  166.     kUSBStorageSFF8070iSubclass            = 5,
  167.     kUSBStorageSCSITransparentSubclass    = 6
  168. };
  169.  
  170. typedef CALLBACK_API_C( OSStatus , StandardDialogProcPtr )(    DriverRefNum drvrRefNum, UInt16 messageNumber );
  171.  
  172. #define kCurrentUSBStorageClassDispatchTableVersion        0x00000001
  173.  
  174. struct StorageClassShimDispatchTable 
  175. {
  176.     StandardDialogProcPtr    DisplayDialog;
  177.     StandardDialogProcPtr    RemoveDialog;
  178. };
  179.  
  180. typedef struct StorageClassShimDispatchTable    StorageClassShimDispatchTable;
  181. typedef StorageClassShimDispatchTable *            StorageClassShimDispatchTablePtr;
  182.  
  183. struct USBStorageClassSetupTable 
  184. {
  185.     UInt32                                dispatchTableVersion;
  186.     USBDeviceRef                         usbDeviceRef;
  187.     USBDeviceRef                         usbParentRef;
  188.     UInt8                                 usbSubClass;
  189.     UInt16                                 usbVendor;
  190.     UInt16                                 usbProduct;
  191.     StorageClassShimDispatchTablePtr    shimDispatchTable;
  192.     StorageClassDispatchTablePtr        theStorageClassDispatchTable;
  193. };
  194.  
  195. typedef struct USBStorageClassSetupTable    USBStorageClassSetupTable;
  196. typedef USBStorageClassSetupTable *            USBStorageClassSetupTablePtr;
  197.  
  198. #endif